package cn.gson.springboot.controllers;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import cn.gson.springboot.model.pojos.FactoryYk;
import cn.gson.springboot.model.service.CheckYkService;
import cn.gson.springboot.model.service.FactoryYkService;

@Controller
public class CheckYkController {
	@Autowired
	private CheckYkService cks;
	
	//查询所有
	@RequestMapping("pandsy")
	@ResponseBody
	public Map<String,Object> hosLikeTableSmt(
			@RequestParam("page")int page,
			@RequestParam("rows")int rows,String drug_period){
		//进行分页
		Page<Object> pg = PageHelper.startPage(page, rows);
		JSONArray findall=cks.pandiansuoyou(drug_period);
			
		//进行数据格式转换和封装
		Map<String,Object> map = new HashMap<>();
		map.put("total", pg.getTotal());//封装总记录数
		map.put("rows", findall);//封装当前页的内容
			
		return map; 
	}
	
	//盘点详情
	@RequestMapping("pandxqid")
	@ResponseBody
	public JSONArray pandianxq(Integer inventory_yk_id) {
		JSONArray pandianxq = cks.pandianxq(inventory_yk_id);
		//System.out.println(findgysyp.toString());
		return pandianxq;
	}
}
